﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.Hosting;

namespace EPiBoost.Core.Helpers.Resources
{
	internal class ResourceVirtualFile : VirtualFile
	{
		private readonly string _resourceName;
		private readonly bool _physicalResource;
		public ResourceVirtualFile(string virtualPath, string resourceName, bool physicalResource)
			: base(virtualPath)
		{
			_resourceName = resourceName;
			_physicalResource = physicalResource;
		}
		public override Stream Open()
		{
			if (_physicalResource)
				return File.OpenRead(_resourceName);

			return Assembly.GetExecutingAssembly().GetManifestResourceStream(this._resourceName);
		}
	}
}
